function interp2pix

% interp2pix
%
% syntax: Assumes that pix2interp has already been called.
% Called from image's uicontextmenu to reset the interpolated map 
% to the pixelated version.

% editing: gs 2004

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

himg = gco; 

% uicontextmenu
cmenu = uicontextmenu;
set(himg, 'UIContextMenu', cmenu);
% cb1 = ['pix2interp'];
item1 = uimenu(cmenu, 'Label', 'pixels', 'Callback', 'interp2pix', 'Checked', 'on');
item2 = uimenu(cmenu, 'Label', 'interpolated', 'Callback', 'pix2interp', 'Checked', 'off');

% set the lims (otherwise won't work with a plot
% whose axes lims were not set explicitly)
lims = get(gca, 'XLim'); 
set(gca, 'XLim', lims); 
lims = get(gca, 'YLim'); 
set(gca, 'YLim', lims); 

% get the original map data
Mraw = get(himg, 'UserData');
MrawSize = size(Mraw);
Mxdata = get(himg, 'XData');
Mydata = get(himg, 'YData');
M = Mraw;


% replace the original map with the interpolated one
set(himg, 'CData', Mraw); % return

% % 
% set(gca, 'XTickLabel', '');
% step = (max(Mxdata)-min(Mxdata))/(MrawSize(1)-1);
% vec = min(Mxdata):step:max(Mxdata);
% set(gca, 'XTick', vec);
% 
% set(gca, 'YTickLabel', '');
% step = (max(Mydata)-min(Mydata))/(MrawSize(2)-1);
% vec = min(Mydata):step:max(Mydata);
% set(gca, 'YTick', vec);
set(gca, 'XTickMode', 'auto', 'XTickLabelMode', 'auto', 'YTickMode', 'auto', 'YTickLabelMode', 'auto');

% contour level could go here



% [X,Y] = meshgrid(X,Y);
% XI = 
% 
% ZI = interp2(X,Y,Z,XI,YI,'cubic')

